<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>留学生管理系统</title>
        <link rel="stylesheet" href="${path}/css/admin3.css">
        <link rel="stylesheet" href="${path}/css/student.css">
        <script type="text/javascript" src="${path}/js/jquery.min.js"></script>
        <script>
            var _current_item = "#score";
        </script>
    </head>

    <body>        <input type="hidden" value="${session.passportNo}" id="PN">

        <!--header-->
        <div id="header"></div>
        <div id="main">
            <div id="side-menu"></div>

            <div id="container">
                <div id="inner-border">
                  

                        <div class="st1">
                            <#if term?exists>
                            <form action="${path}/studentscore/search" method="post">
                                <span class="st2">term</span> 
                                <div class="st3">
                                    <select name="term" id="term" class="st5">
                                        <#list term as t>
                                        <#if t.current==1>
                                        <option value="${t.termValue}" selected="selected">${t.termValue}</option>
                                        <#else>
                                        <option value="${t.termValue}">${t.termValue}</option>
                                        </#if>
                                        </#list>  
                                    </select>
                                </div>
                                <input type="button" onclick="ajaxsearch()" value="search" class="button st4">
                            </form>
                            </#if>
                            
                          <button style="position:relative;left:-5%" id="exPdf">Export PDF</button>
                        </div>
                        <script type="text/javascript">
                            function ajaxsearch() {
                                $.ajax({
                                    type: "post",
                                    url: '${path}/studentscore/ajaxsearch',
                                    data: {
                                        term: $('#term').val(),
                                    },
                                    datatype: "json",
                                    success: function (data) {                                                                         
                                      // alert(data.studentGrade[0]["collegeName"]);
                                        if (data.error == 0){
                                            alert("No data");
                                        $('#stuscore').dataTable().fnClearTable();
                                    }
                                        else {
                                            $(document).ready(function () {
                                                $('#stuscore').dataTable().fnClearTable();

                                                for (var i = 0; i < data.studentGrade.length; i++) {
                                                    $('#stuscore').dataTable().fnAddData([data.studentGrade[i]["courseNo"], data.studentGrade[i]["courseName"], data.studentGrade[i]["collegeName"], data.studentGrade[i]["credit"], data.studentGrade[i]["dailyGrade"], data.studentGrade[i]["experimentalGrade"], data.studentGrade[i]["otherGrade"], data.studentGrade[i]["finalGrade"], data.studentGrade[i]["grade"]]);

                                                }
                                            });

                                        }
                                    }
                                });
                            }
                        </script>

                     
                            <table class="table table-bordered" id="stuscore">
                                <thead>
                                    <tr>
                                        <th>course number</th>
                                        <th>course name</th>
                                        <th>college</th>
                                        <th>course credit</th>
                                        <th>usual-time mark</th>
                                        <th>experiment mark</th>
                                        <th>other parts mark</th>
                                        <th>final mark</th>
                                        <th>overall mark</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <#if studentGrade?exists>
                                    <#list studentGrade as sg>
                                    <tr>
                                        <td>${sg.courseNo}</td>
                                        <td>${sg.courseName}</td>
                                        <td>${sg.collegeName}</td>
                                        <td>${sg.credit}</td>
                                        <td>${sg.dailyGrade!}</td>
                                        <td>${sg.experimentalGrade!}</td>
                                        <td>${sg.otherGrade!}</td>
                                        <td>${sg.finalGrade!}</td>
                                        <td>${sg.grade!}</td>
                                    </tr>
                                    </#list>
                                    </#if>
                                </tbody>
                            </table>
                      
                    </div>
                    
                </div>
            </div>
<div id="footer"></div>
        <script type="text/javascript" src="${path}/js/student-main-appearance.js"></script>
        <script src="${path}/js/amazeui.min.js"></script>
        <script src="${path}/bower_components/jquery/dist/jquery.min.js"></script>
        <!-- Metis Menu Plugin JavaScript -->
        <script
        src="${path}/bower_components/metisMenu/dist/metisMenu.min.js"></script>

        <!-- DataTables JavaScript -->
        <script
        src="${path}/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
        <script
        src="${path}/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>

        <script type="text/javascript">
              $(document).ready(function () {
                  $('#stuscore').DataTable({
                      responsive: true,
                      ordering: false,
                      searching: false,
                      "bLengthChange": false,
                      "bRetrieve": true,
                      "bFilter": true//过滤功能

                  });
              });
              
              $("#exPdf").on("click",function(){
            	  var term = $("#term").val();
            	 // alert(term);
            	  window.location.href ="${path}/studentpdf/index?termValue="+term;
            	  /* 
            	  $.ajax({
            	  	type:"post",
            	  	url:"${path}/studentpdf/index",
            	  	data:{
            	  		termValue:term,
            	  	},
            	  	datatype:"json",
            	  	success:function(data){
            	  		alert("成功");
            	  	}
            	  }); */
              })
        </script>
    </body>
</html>
